package cn.mldn.microboot.controller;


import cn.mldn.microboot.service.IMessageService;
import cn.mldn.microboot.util.controller.AbstractBaseController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * description:
 * Created by gy on 2017/8/9.
 */
@RestController
public class MessageController extends AbstractBaseController {

    @Resource(name = "messageService")
    private IMessageService iMessageService;


    @RequestMapping(value = "/",method = RequestMethod.GET)
    public String index(){
        return this.iMessageService.info();
    }


    @RequestMapping(value = "/welcome",method = RequestMethod.GET)
    public String welcome(String msg){
        return super.getMessage("welcome.msg",msg);
    }

    @RequestMapping(value = "/echo/{msg}",method = RequestMethod.GET)
    public String echo(@PathVariable("msg") String msg){
        return "【echo】" + msg;
    }

    @RequestMapping("/object")
    public void info(HttpServletRequest request){
        System.out.println(request.getServletContext().getRealPath(""));
    }

    @RequestMapping("/home")
    public String home() {
        return "www.mldn.cn!";
    }

}
